#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

void bubble_sort(int arr[],int sz)
{
	int i = 0;
	int j = 0;
	int t = 0;
	for (i = 0; i < sz - 1; i++)
	{
		for (j = 0; j < sz - i - 1; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				t = arr[j + 1];
				arr[j + 1] = arr[j];
				arr[j] = t;
			}
		}
	}
}
int main()
{
	int arr1[1000] = { 0 };
	int arr2[1000] = { 0 };
	int arr3[2000] = { 0 };
	int n, m;
	int i = 0;
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr2[i]);
	}
	for (i = 0; i < n + m; i++)
	{
		if (i < n)
		{
			arr3[i] = arr1[i];
		}
		else if (i >= n && i < n+m)
		{
			arr3[i] = arr2[i - n];
		}
	}
	int sz = n + m;
	bubble_sort(arr3,sz);
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr3[i]);
	}
	return 0;
}